

package com.hazelcast.vector.impl;

import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

public class VectorStringUtil {
    private VectorStringUtil() {
    }

    private static String toString(Object value) {
        if (value instanceof float[] array) {
            return Arrays.toString(array);
        } else {
            return Objects.toString(value);
        }
    }

    public static String mapToString(Map<String, ?> data) {
        if (data == null) {
            return "null";
        }
        String dataString = data.keySet().stream().map(key -> key + "=" + toString(data.get(key))).collect(Collectors.joining(", ", "{", "}"));
        return dataString;
    }
}
